<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.14.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>DM-CtrlH7-BF-DevProgram: master_process</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectlogo"><img alt="Logo" src="50x5.png"/></td>
  <td id="projectalign">
   <div id="projectname">DM-CtrlH7-BF-DevProgram<span id="projectnumber">&#160;beta 0.1</span>
   </div>
   <div id="projectbrief">C.ONE Studio Damiao Development Board Framework</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.14.0 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search/",'.html');
</script>
<script type="text/javascript">
$(function() { codefold.init(); });
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search',true);
  $(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(function(){initNavTree('md__c_1_2_users_2_a_s_u_s_2_desktop_2dm-ctrl_h7-balance-9025test_2modules_2master__machine_2master__process.html','',''); });
</script>
<div id="container">
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div><div class="header">
  <div class="headertitle"><div class="title">master_process </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p><a class="anchor" id="autotoc_md55"></a></p>
<p align="right"></p>
<p><a href="#" onclick="location.href='mai'+'lto:'+'neo'+'zn'+'g1@'+'hn'+'u.e'+'du'+'.cn'; return false;">neozn<span class="obfuscator">.nosp@m.</span>g1@h<span class="obfuscator">.nosp@m.</span>nu.ed<span class="obfuscator">.nosp@m.</span>u.cn</a></p>
<blockquote class="doxtable">
<p>TODO:</p>
<ol type="1">
<li>补全标志位解析和发送设置的代码</li>
<li>增加发送给视觉数据的时间戳用于数据对齐 </li>
</ol>
</blockquote>
<h1 class="doxsection"><a class="anchor" id="autotoc_md56"></a>
总览和封装说明</h1>
<p>模块包含了和视觉通信的初始化、向上位机发送信息的接口和模块的串口的回调处理。接口的定义统一，可以方便的替换成其他通信方式，如CAN。</p>
<h1 class="doxsection"><a class="anchor" id="autotoc_md57"></a>
代码结构</h1>
<p>.h文件内包括了外部接口和与**视觉上位机通信的数据结构定义**，以及模块对应的宏。c文件内为私有函数和外部接口的定义。</p>
<p>本模块主要是对协议解析的处理和协议发送的封装，实际内容不多。协议相关内容都在<span class="tt"><a class="el" href="seasky__protocol_8h_source.html">seasky_protocol.h</a></span>中。</p>
<h1 class="doxsection"><a class="anchor" id="autotoc_md58"></a>
类型定义</h1>
<p>和视觉通信所必须的标志位和数据。包括开火模式，目标状态，目标类型，接收/发送数据结构体。</p>
<div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keyword">enum</span></div>
<div class="line">{</div>
<div class="line">    NO_FIRE = 0,</div>
<div class="line">    AUTO_FIRE = 1,</div>
<div class="line">    AUTO_AIM = 2</div>
<div class="line">} Fire_Mode_e;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">typedef</span> <span class="keyword">enum</span></div>
<div class="line">{</div>
<div class="line">    NO_TARGET = 0,</div>
<div class="line">    TARGET_CONVERGING = 1,</div>
<div class="line">    READY_TO_FIRE = 2</div>
<div class="line">} Target_State_e;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">typedef</span> <span class="keyword">enum</span></div>
<div class="line">{</div>
<div class="line">    NO_TARGET_NUM = 0,</div>
<div class="line">    HERO1 = 1,</div>
<div class="line">    ENGINEER2 = 2,</div>
<div class="line">    INFANTRY3 = 3,</div>
<div class="line">    INFANTRY4 = 4,</div>
<div class="line">    INFANTRY5 = 5,</div>
<div class="line">    OUTPOST = 6,</div>
<div class="line">    SENTRY = 7,</div>
<div class="line">    BASE = 8</div>
<div class="line">} Target_Type_e;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">typedef</span> <span class="keyword">struct</span></div>
<div class="line">{</div>
<div class="line">    Fire_Mode_e fire_mode;</div>
<div class="line">    Target_State_e target_state;</div>
<div class="line">    Target_Type_e target_type;</div>
<div class="line"> </div>
<div class="line">    <span class="keywordtype">float</span> pitch;</div>
<div class="line">    <span class="keywordtype">float</span> yaw;</div>
<div class="line">} <a class="code hl_struct" href="struct_vision___recv__s.html">Vision_Recv_s</a>;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">typedef</span> <span class="keyword">enum</span></div>
<div class="line">{</div>
<div class="line">    BLUE = 0,</div>
<div class="line">    RED = 1</div>
<div class="line">} Enemy_Color_e;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">typedef</span> <span class="keyword">enum</span></div>
<div class="line">{</div>
<div class="line">    MODE_AIM = 0,</div>
<div class="line">    MODE_SMALL_BUFF = 1,</div>
<div class="line">    MODE_BIG_BUFF = 2</div>
<div class="line">} Work_Mode_e;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">typedef</span> <span class="keyword">enum</span></div>
<div class="line">{</div>
<div class="line">    BIG_AMU_10 = 10,</div>
<div class="line">    SMALL_AMU_15 = 15,</div>
<div class="line">    BIG_AMU_16 = 16,</div>
<div class="line">    SMALL_AMU_18 = 18,</div>
<div class="line">    SMALL_AMU_30 = 30,</div>
<div class="line">} Bullet_Speed_e;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">typedef</span> <span class="keyword">struct</span></div>
<div class="line">{</div>
<div class="line">    Enemy_Color_e enemy_color;</div>
<div class="line">    Work_Mode_e work_mode;</div>
<div class="line">    Bullet_Speed_e bullet_speed;</div>
<div class="line"> </div>
<div class="line">    <span class="keywordtype">float</span> yaw;</div>
<div class="line">    <span class="keywordtype">float</span> pitch;</div>
<div class="line">    <span class="keywordtype">float</span> roll;</div>
<div class="line">} <a class="code hl_struct" href="struct_vision___send__s.html">Vision_Send_s</a>;</div>
<div class="ttc" id="astruct_vision___recv__s_html"><div class="ttname"><a href="struct_vision___recv__s.html">Vision_Recv_s</a></div><div class="ttdef"><b>Definition</b> master_process.h:39</div></div>
<div class="ttc" id="astruct_vision___send__s_html"><div class="ttname"><a href="struct_vision___send__s.html">Vision_Send_s</a></div><div class="ttdef"><b>Definition</b> master_process.h:73</div></div>
</div><!-- fragment --><h1 class="doxsection"><a class="anchor" id="autotoc_md59"></a>
外部接口</h1>
<div class="fragment"><div class="line"><a class="code hl_struct" href="struct_vision___recv__s.html">Vision_Recv_s</a> *VisionInit(<a class="code hl_typedef" href="group___u_a_r_t___exported___types.html#ga5de4a49eb132735325e706f406c69d6e">UART_HandleTypeDef</a> *_handle);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">void</span> VisionSend(<a class="code hl_struct" href="struct_vision___send__s.html">Vision_Send_s</a> *send);</div>
<div class="ttc" id="agroup___u_a_r_t___exported___types_html_ga5de4a49eb132735325e706f406c69d6e"><div class="ttname"><a href="group___u_a_r_t___exported___types.html#ga5de4a49eb132735325e706f406c69d6e">UART_HandleTypeDef</a></div><div class="ttdeci">struct __UART_HandleTypeDef UART_HandleTypeDef</div><div class="ttdoc">UART handle Structure definition.</div></div>
</div><!-- fragment --><p>给<span class="tt">VisionInit()</span>传入串口handle，将初始化一个视觉通信模块，返回值是接收数据的结构体指针。拥有视觉模块的应用应该在初始化中调用此函数，并保存返回值的指针。</p>
<p>调用<span class="tt">VisionSend</span>并传入填好发送数据的结构体，会通过底层的通信模块向视觉发送一帧报文。</p>
<h1 class="doxsection"><a class="anchor" id="autotoc_md60"></a>
私有函数和变量</h1>
<div class="fragment"><div class="line"><span class="keyword">static</span> <a class="code hl_struct" href="struct_vision___recv__s.html">Vision_Recv_s</a> recv_data;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">static</span> usart_instance *vision_usart_instance;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">static</span> <span class="keywordtype">void</span> DecodeVision()</div>
<div class="line">{</div>
<div class="line">    <span class="keyword">static</span> uint16_t flag_register;</div>
<div class="line">    get_protocol_info(vision_usart_instance-&gt;recv_buff, &amp;flag_register, (uint8_t*)&amp;recv_data.pitch);</div>
<div class="line">    <span class="comment">// TODO: code to resolve flag_register;</span></div>
<div class="line">}</div>
</div><!-- fragment --><p>第一个是保存接收数据的结构体，其指针将会在初始化的时候返回给拥有者。目前最多只能配置一个视觉模块。</p>
<p>第二个是该模块拥有的串口实例指针，用于调度其底层的发送和接收。如果要换成CAN/SPI等，替换成对应实例，并修改初始化和发送的实现即可。</p>
<p><span class="tt">DecodeVision()</span>是解析视觉接收数据的回调函数，会在串口接收回调中被调用。如果修改通信协议，只需要更改</p>
<p><span class="tt">get_protocol_info()</span>。 </p>
</div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<div id="page-nav" class="page-nav-panel">
<div id="page-nav-resize-handle"></div>
<div id="page-nav-tree">
<div id="page-nav-contents">
</div><!-- page-nav-contents -->
</div><!-- page-nav-tree -->
</div><!-- page-nav -->
</div><!-- container -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.14.0 </li>
  </ul>
</div>
</body>
</html>
